package com.imooc;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import com.imooc.netty.WSServer;

/***
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 *
 * .............................................
 *          佛祖保佑             永无BUG
 */
/***
 * @ClassName: NettyBooter
 * @Description:
 * @author: wupeng
 * @date: 2018年12月21日 下午5:03:57
 */
@Component
public class NettyBooter implements ApplicationListener<ContextRefreshedEvent>
{

	@Override
	public void onApplicationEvent(ContextRefreshedEvent event)
	{
		if (event.getApplicationContext().getParent() == null)
		{
			try
			{
				WSServer.getInstance().start();
			} catch (Exception e)
			{
				e.printStackTrace();
			}
		}
	}

}
